/**
 * @File name: main.c
 * @Synopsis:
 * @Author: xing.dai@aliyun.com
 * @Version: 0.0.1
 * @Date: 2018-12-21 19:47
 */

#include <stdio.h>
#include <unistd.h>
#include <stdint.h>

#include "init.h"

extern void do_initcalls(int level);


#pragma pack(8)
struct test_pack{
	int *cc;
	const char *name;
	int a;
};
#pragma pack()

int a_init(void)
{
	printf("%s: exec.\n", __func__);
	return 0;
}

#ifdef SINGLE
DECLARE_INIT(a_init);
#else
CONFIG_INIT(aaa, a_init, 1, NULL);
#endif

#if 1
int b_init(void)
{
	printf("%s: exec.\n", __func__);
	return 0;
}
#ifdef SINGLE
DECLARE_INIT(b_init);
#else
CONFIG_INIT(bbb, b_init, 1, NULL);
#endif


int c_init(void)
{
	printf("%s: exec.\n", __func__);
	return 0;
}
#ifdef SINGLE
DECLARE_INIT(c_init);
#else
CONFIG_INIT(c, c_init, 1, NULL);
#endif
#endif
/*
 * DECLARE_INIT like below:
 * static init_call _fn_a_init __attribute__((unused, section(".myinit"))) = a_init;
 * static init_call _fn_b_init __attribute__((unused, section(".myinit"))) = a_init;
 * static init_call _fn_a_init __attribute__((unused, section(".myinit"))) = a_init;
 */

int main(void)
{

	printf("test sizeof: %ld\n", sizeof(struct test_pack));
	do_initcalls(0);
	return 0;
}

